package emulator.unittest.hardware.nmos6502.timing;


import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

import emulator.EmulatorException;

public class AbsoluteTest {

	TimingTestBase test_base = null;
	
	@Before
	public void setUp() throws Exception {
		test_base = new TimingTestBase();
	}
	
	@Test
	public void testADC() throws EmulatorException
	{
		assertEquals(4, getCycles(0x6D));
	}
	
	@Test
	public void testAND() throws EmulatorException
	{
		assertEquals(4, getCycles(0x2D));
	}
	
	@Test
	public void testASL() throws EmulatorException
	{
		assertEquals(6, getCycles(0x0E));
	}
	
	@Test
	public void testBIT() throws EmulatorException
	{
		assertEquals(4, getCycles(0x2C));
	}
	
	@Test
	public void testCMP() throws EmulatorException
	{
		assertEquals(4, getCycles(0xCD));
	}
	
	@Test
	public void testCPX() throws EmulatorException
	{
		assertEquals(4, getCycles(0xEC));
	}
	
	@Test
	public void testCPY() throws EmulatorException
	{
		assertEquals(4, getCycles(0xCC));
	}
	
	@Test
	public void testDEC() throws EmulatorException
	{
		assertEquals(6, getCycles(0xCE));
	}
	
	@Test
	public void testEOR() throws EmulatorException
	{
		assertEquals(4, getCycles(0x4D));
	}
	
	@Test
	public void testINC() throws EmulatorException
	{
		assertEquals(6, getCycles(0xEE));
	}
	
	@Test
	public void testJMP() throws EmulatorException
	{
		assertEquals(3, getCycles(0x4C));
	}
	
	@Test
	public void testJSR() throws EmulatorException
	{
		assertEquals(6, getCycles(0x20));
	}
	
	@Test
	public void testLDA() throws EmulatorException
	{
		assertEquals(4, getCycles(0xAD));
	}
	
	@Test
	public void testLDX() throws EmulatorException
	{
		assertEquals(4, getCycles(0xAE));
	}
	
	@Test
	public void testLDY() throws EmulatorException
	{
		assertEquals(4, getCycles(0xAC));
	}

	@Test
	public void testLSR() throws EmulatorException
	{
		assertEquals(6, getCycles(0x4E));
	}

	@Test
	public void testORA() throws EmulatorException
	{
		assertEquals(4, getCycles(0x0D));
	}

	@Test
	public void testROL() throws EmulatorException
	{
		assertEquals(6, getCycles(0x2E));
	}

	@Test
	public void testROR() throws EmulatorException
	{
		assertEquals(6, getCycles(0x6E));
	}

	@Test
	public void testSBC() throws EmulatorException
	{
		assertEquals(4, getCycles(0xED));
	}

	@Test
	public void testSTA() throws EmulatorException
	{
		assertEquals(4, getCycles(0x8D));
	}

	@Test
	public void testSTX() throws EmulatorException
	{
		assertEquals(4, getCycles(0x8E));
	}

	@Test
	public void testSTY() throws EmulatorException
	{
		assertEquals(4, getCycles(0x8C));
	}

	private int getCycles(int opcode) throws EmulatorException
	{
		test_base.setCommand(0, opcode, 0x44, 0x01);
		test_base.execute();
		return test_base.getElapsedCycles();
	}
}
